package com.fly.push.flux.hight;

import org.springframework.stereotype.Service;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Sinks;

@Service
public class SinksSsePublisherService
{
    // 区别 Sinks.many().unicast()
    Sinks.Many<String> sink = Sinks.many().multicast().onBackpressureBuffer();
    
    public Flux<String> getMessages()
    {
        return sink.asFlux();
    }
    
    public void publishMessage(String message)
    {
        sink.tryEmitNext(message);
    }
}